//
//  ViewController.m
//  MKAPITestApp
//
//  Created by 苏尚进 on 2022/9/16.
//  Copyright © 2022 moon. All rights reserved.
//

#import "ViewController.h"
#import <MKAPI/MKAPI.h>

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor greenColor];
    
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    MKAPIHttpRequestAFNetworking *requestTask = [[MKAPIHttpRequestAFNetworking alloc] init];
    requestTask.validateServerHttpsCerts = NO;
    MKAPIRequestParamJSON *jsonParam = [[MKAPIRequestParamJSON alloc] init];
    jsonParam.httpMethod = MKAPIHttpRequestMethodPOST;
    jsonParam.url = @"https://httpbingo.org/post";
    requestTask.requestParam = jsonParam;
    [self mkapi_runTask:requestTask withCompletion:^(ViewController *self, MKAPIHttpRequestAFNetworking *requestTask, BOOL success, NSError * _Nullable error) {
        NSLog(@"responde:%@",requestTask.responseJson);
    }];
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self mkapi_cancelWaitingTasks];
}
- (void)dealloc{
    [self mkapi_cancelWaitingTasks];
}

@end
